
package com.scalar.chiptrack;

import java.util.HashMap;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.scalar.chiptrack.commons.SessionKeys;


public final class LoginForm extends ChipTrackActionForm {
    
    private String m_userId = null;
    private String m_password = null;
    
    public LoginForm() {
    }
    
    public String getUserId() {
        return m_userId;
    }
    public void setUserId (String id) {
        m_userId = id;
    }
    
    public String getPassword() {
        return m_password;
    }
    public void setPassword (String password) {
        m_password = password;
    }
    
    public ActionErrors validate (ActionMapping mapping, javax.servlet.http.HttpServletRequest request) {

        HashMap errors = new HashMap();

        if ((m_userId == null) || (m_userId.trim().length() == 0)) {
            errors.put ("User Name", "User ID required");
        }

        if ((m_password == null) || (m_password.length() == 0)) {
            errors.put ("Password", "Password required");
        }
        
        request.setAttribute(SessionKeys.ERROR_MESSAGES, errors);
        return null;
    }
}